storBattery = new Vue({
	el: "#storBattery",
	data: {
		title:'',
		currentUser:'', // 当前用户信息
		checklist: [],
		parentObject:{},
		deviceSwitch: '',
		checkItemNoteList: [],
		nowDate: '',
		fileIds:'',
		fileList:[],
	},
	components:{
		processlog, // 流程日志	
	},
	created: function() {
		let _this = this
		_this.currentUser = JSON.parse(localStorage.getItem("neiosUser"))
		_this.parentObject = JSON.parse(localStorage.getItem("neiosGoDetail")).obj
		if (_this.parentObject.workType == '0102') {
			_this.title = "场用电系统"
		} else if (_this.parentObject.workType == '0103') {
			_this.title = "UPS系统"
		} else if (_this.parentObject.workType == '0104') {
			_this.title = "事故照明系统"
		} else if (_this.parentObject.workType == '0105') {
			_this.title = "主变风冷系统"
		} else if (_this.parentObject.workType == '0106') {
			_this.title = "直流系统"
		} else if (_this.parentObject.workType == '0107') {
			_this.title = "消防系统"
		} else if (_this.parentObject.workType == '0108') {
			_this.title = "通信系统"
		}
		// 获取码表
		let dictCodes = 'CHECK_RESULT_TYPE';
		mui.neiosCommon.queryDict(dictCodes,function(data){
			if (data != '') {
				_this.checklist = data.CHECK_RESULT_TYPE 
				_this.queryDetail() // 查询详情
				_this.getNowdate()
			}
		})
	},
	methods: {
		// 码表转换
		dictChange (data) {
			return mui.neiosCommon.dictTransform(this.checklist,data)
		},
		//获取当前时间
		getNowdate() {
			var date = new Date()
			var year = date.getFullYear()
			var month = date.getMonth()
			var day = date.getDate()
			month = month*1 + 1
			if (month.toString().length < 2) {
				month = '0' + month
			}
			if (day.toString().length < 2) {
				day = '0' + day
			}
			this.nowDate = year + '-' + month + '-' + day
		},
		// 查询详情
		queryDetail() {
			var that = this
			var param = {
				companyCode: this.currentUser.companyCode,
				deviceSwitchId: "",
				name: this.currentUser.name,
				stationCode: localStorage.getItem('neiosStationCode'),
				userId: this.currentUser.userId,
				workId: this.parentObject.workId,
				workType: this.parentObject.workType,
			}
			mui.neiosRequst.httpRequst('/app/regularWork/deviceSwitch/getCheckItems', param,
				function(data) {
					that.deviceSwitch = data.data.data.deviceSwitch
					that.checkItemNoteList = data.data.data.checkItemNoteList
					that.fileIds = data.data.data.attachIds;
					if (that.fileIds == '' ||
					that.fileIds == null || 
					that.fileIds == undefined) {
						that.fileIds = ''
					}
					that.queryFiles(that.fileIds)
					if (!that.deviceSwitch.switchStaffCode) {
						that.deviceSwitch.switchStaffCode = that.currentUser.userId
						that.deviceSwitch.switchStaffName = that.currentUser.name
					}
					if (that.deviceSwitch.approveStaffName == null) {
						that.deviceSwitch.approveStaffName = ''
					} else {
						that.deviceSwitch.approveStaffName = '[' + that.deviceSwitch.approveStaffCode + ']' + that.deviceSwitch.approveStaffName
					}
		
					if (that.deviceSwitch.responsibleStaffName == null) {
						that.deviceSwitch.responsibleStaffName = ''
					} else {
						that.deviceSwitch.responsibleStaffName = '[' + that.deviceSwitch.responsibleStaffCode + ']' + that.deviceSwitch.responsibleStaffName
					}
				},
				function(data) {
					mui.toast('获取数据失败,请稍后再试！')
				})
		},
		// 获取附件
		queryFiles (fileIds) {
			let _this = this
			let fileParams = {
				fileIds:fileIds
			}
			mui.neiosRequst.httpRequst('/app/common/getFileList', fileParams,
				function(data) {
					if (data.code == '0') {
						if (data.data != '' && data.data != null && data.data != undefined) {
							_this.fileList = data.data
						} else {
							_this.fileList = []
						}
					} else {
						mui.toast('获取附件失败，请稍后重试！')
					}
				},
				function() {
					mui.toast('获取附件失败，请稍后重试！')
				}
			);
		},
		// 下载
		downloadFile(item){
			let url = "/app/common/downloadFile";
			let param = {};
			param.fileId = item.fileId;
			mui.neiosCommon.downLoadFile(param,function(ret){
				mui.plusReady(function () {
					plus.nativeUI.closeWaiting();
				})
				var callbackID = plus.bridge.callbackId(function(ret){
					mui.toast(ret[0])
				}, function(err){
					mui.toast('文件下载失败')
				});
				alert(item.fileName)
				plus.bridge.execSync( "FileHelper", "doFileSave", [callbackID, ret, item.fileName, "Argus3", "Argus4"] )
			},function(err){
				mui.plusReady(function () {
					plus.nativeUI.closeWaiting();
				})
				mui.toast('文件下载失败')
			});
		},
		// 返回
		goBack () {
			mui.back()
		}
	}
});